﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using App.Common;
using QxFramework.Core;

public class MonoSpawner : MonoBehaviour
{
    public bool NotActivated;
    [SerializeField]
    public List<SpawnData> _spawnData;

    [HideInInspector]
    public bool NotStartOnScene = false;

    private void OnEnable()
    {
        //if (!NotStartOnScene)
        //{
        //    Init();
        //}
        transform.SetParent(GameObject.Find("SceneObjs").transform);
    }
    private void Init()
    {
        //if (!GameMgr.Get<ISpawnManager>().GetSpawnObjDatas()._spawnData.ContainsKey(gameObject.name))
        //{
        //    SpawnObjData spawnObjData = new SpawnObjData();
        //    spawnObjData.PrefabName = gameObject.name;
        //    spawnObjData._spawnData = new List<SpawnData>();
        //    spawnObjData._SpawnDataRecord = new List<SpawnDataRecord>();
        //    for (int i=0;i< _spawnData.Count; i++)
        //    {
        //        spawnObjData._spawnData.Add(_spawnData[i]);
        //        spawnObjData._SpawnDataRecord.Add(new SpawnDataRecord());
        //    }
        //    spawnObjData.Pos = transform.position;
        //    spawnObjData.NotActivated = NotActivated;

        //    GameMgr.Get<ISpawnManager>().AddObj(gameObject.name,out GameObject gmobj);
        //    GameMgr.Get<ISpawnManager>().AddSpawner(gameObject.name, spawnObjData);
        //}
    }
    public void OnDrawGizmos()
    {
        if (_spawnData.Count == 0)
            return;
        if (_spawnData[0].Name.Contains("Player"))
        {
            Gizmos.color = new Color(0, 0, 1, 0.5f);
        }
        else
        {
            Gizmos.color = new Color(1, 0, 0, 0.5f);
        }
        Gizmos.DrawSphere(transform.position, 1);
    }
}
